<?php
/**
 * 地区表模型
 * 
 * @author:  will.lee <im.will.lee@gmail.com>
 * @version: 1.0
 */
 class AreaModel extends AppModel
 {
     /**
      * 获取详细地区
      * 
      * @param  int $area_id
      * @return string
      */
     public function getAreaDetail($area_id = null)
     {
         $return = array
         (
             'province' => null,
             'city'     => null,
             'district' => null
         );
         if(!is_null($area_id) && $area_id != '')
         {
             $where  = array('id' => $area_id);
             $detail = $this->field('join_name')->where($where)->find();
             if(!empty($detail))
             {
                 $detail = explode('|',$detail['join_name']);
                 $return['province'] = isset($detail[0]) ? $detail[0] : null;
                 $return['city']     = isset($detail[1]) ? $detail[1] : null;
                 $return['district'] = isset($detail[2]) ? $detail[2] : null;
             }
         }
         return $return;
     }
 }